<template>
  <div class="wrap">
    <div class="ech-title">
      <p>用户支付渠道分布</p>
      <span>计算于 :{{new Date()| fmtdate}}</span>
    </div>
    <div id="ech_2"></div>
  </div>
</template>
<script>
export default {
  props: {
    pieData: {
      type: null,
      default: null
    }
  },
  methods: {
    draw() {
      let myChart = this.$echarts.init(document.getElementById("ech_2"));
      var option = {
        tooltip: {
          trigger: "item",
          formatter: "{a} <br/>{b} : {c} ({d}%)"
        },

        series: [
          {
            name: "用户支付渠道",
            type: "pie",
            radius: "55%",
            center: ["50%", "60%"],
            data: [
              {
                value: this.pieData[0].count,
                name: this.pieData[0].payType,
                itemStyle: { color: "#1488E2" }
              },
             
              {
                value: this.pieData[2].count,
                name: this.pieData[2].payType,
                itemStyle: { color: "#F3AE6E" }
              },
               {
                value: this.pieData[1].count,
                name: this.pieData[1].payType,
                itemStyle: { color: "#E94C81" }
              },
              {
                value: this.pieData[3].count,
                name: this.pieData[3].payType,
                itemStyle: { color: "#f5dd2a" }
              },
               {
                value: this.pieData[4].count,
                name: this.pieData[4].payType,
                itemStyle: { color: "#42f10c" }
              },
            ],
            itemStyle: {
              emphasis: {
                shadowchange: 10,
                shadowOffsetX: 0,
                shadowColor: "rgba(0, 0, 0, 0.5)"
              }
            }
          }
        ]
      };

      myChart.setOption(option);
    }
  },
  mounted() {},
  watch: {
    pieData(e) {
      this.draw();
    }
  }
};
</script>
<style lang="scss" scoped>
#ech_2 {
  width: 100%;
  height: 400px;
  background: #fff;
}
.wrap {
  height: 480px;
  background: #fff;
}
.ech-title {
  overflow: hidden;
  padding-top: 15px;
  margin-left: 15px;
  p {
    color: #555;
    font-size: 18px;
  }
  span {
    font-size: 12px;
    color: #555;
    margin-top: 10px;
  }
}
</style>